package defaultPackage;
import java.awt.*;
//import java.util.ArrayList;
public class CursorWindow 
{
	Cursor cursor;
	Tile tile;
	Object[] objects;
	MainClass main;
	
	int textInterval = 16;
	public CursorWindow(Cursor cursor,Tile tile,Object[] objects,MainClass main)
	{
		this.main=main;
		this.cursor = cursor;
		this.tile = tile;
		this.objects = objects;
	}
	
	public void draw(Graphics g)
	{
		int numViewed = 1;
		g.setColor(Color.DARK_GRAY);
		g.fillRect(MainClass.windowXSize - 195, 55, 190, MainClass.menuHeight-60);
		g.setColor(Color.LIGHT_GRAY);
		g.fillRect(MainClass.windowXSize - 195, 78, 190, 5);
		if (cursor.isActive() && !tile.type.getSolid())
		{
			if (tile.oxygen >=80)
				g.setColor(Color.green);
			else if (tile.oxygen <=20)
				g.setColor(Color.red);
			else
				g.setColor(Color.yellow);
			g.drawString("Oxygen at " + tile.getRoundedOxygen() + "%" , MainClass.windowXSize - 195 + 5, 1*textInterval + 55);
			g.setColor(Color.CYAN);
		}
			
			
			
			
			
			
			
			
			
			
		for (int i = 0;i < ObjectManager.numObjects;i++)
		{
			if (objects[i].getX() == cursor.x && objects[i].getY() == cursor.y)
			{
				g.setColor(Color.cyan);
				g.drawString(objects[i].getDesignation(), MainClass.windowXSize - 195 + 5, 2*textInterval + 65);
				
				if (objects[i].isOperational() && objects[i].type.displaysOperational)
				{
					g.setColor(Color.green);
					g.drawString("Operational", MainClass.windowXSize - 195 + 5, 3*textInterval + 65);
				}
				
				else if (objects[i].type.displaysOperational)
				{
					g.setColor(Color.red);
					g.drawString("Not Operational", MainClass.windowXSize - 195 + 5, 3*textInterval + 65);
				}
			}
		}
		for (Person p: main.people.people)
		{
			int barWidth;
			if (!p.isWearingSpaceSuit() || p.personalOxygen <= 0)
			{
				barWidth = (int)(180*p.healthPercent/100);
			}
			else 
				barWidth = (int)(180*p.personalOxygen/100);
			if (p.x == cursor.getX()/10 && p.y == cursor.getY()/10 && !main.people.someonesSelected)
			{
				g.setColor(Color.cyan);
				g.drawString(p.type.designation+" "+p.name,MainClass.windowXSize - 195 + 5, 4*textInterval + 65);
				if (!p.isWearingSpaceSuit() || p.personalOxygen <= 0)
					g.setColor(new Color(150,0,0));
				else
					g.setColor(new Color(0,0,0));
				g.fillRect(MainClass.windowXSize - 195 + 5, 5*textInterval + 55, 180, 10);
				if (!p.isWearingSpaceSuit() || p.personalOxygen <= 0)
					g.setColor(new Color(255,0,0));
				else
					g.setColor(Color.LIGHT_GRAY);
				g.fillRect(MainClass.windowXSize - 195 + 5, 5*textInterval + 55, barWidth, 10);
				if (!p.isWearingSpaceSuit() || p.personalOxygen <= 0)
				{
					g.setColor(Color.white);
					g.drawString("Health "+p.healthPercent+"%", MainClass.windowXSize - 195 + 50, 6*textInterval + 49);
				}
				else 
				{
					if (p.personalOxygen >=80)
						g.setColor(Color.GREEN);
					else if (p.personalOxygen >=35)
						g.setColor(Color.yellow);
					else 
						g.setColor(Color.red);
					
					g.drawString("Air at "+p.personalOxygen+"%", MainClass.windowXSize - 195 + 50, 6*textInterval + 49);
				}
			}
			else if(main.people.someonesSelected && p.isSelected())
			{
				g.setColor(Color.cyan);
				g.drawString(p.type.designation+" "+p.name,MainClass.windowXSize - 195 + 5, 4*textInterval + 65);
				g.setColor(new Color(150,0,0));
				g.fillRect(MainClass.windowXSize - 195 + 5, 5*textInterval + 55, 180, 10);
				g.setColor(new Color(255,0,0));
				g.fillRect(MainClass.windowXSize - 195 + 5, 5*textInterval + 55, barWidth, 10);
			}
		}
	}
}
